using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing ;
using System.Windows.Forms;

namespace PageSetupDialogProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pageSetupDialog1.PageSettings =  new PageSettings();
            pageSetupDialog1.PrinterSettings = new PrinterSettings();
            DialogResult result = pageSetupDialog1.ShowDialog();           
            if (result == DialogResult.OK)
            {
                printDocument1.PrinterSettings = 
                    pageSetupDialog1.PrinterSettings;
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {

            pageSetupDialog1.PageSettings =
         new  PageSettings();

         
            pageSetupDialog1.PrinterSettings =
                new  PrinterSettings();

           
            pageSetupDialog1.ShowNetwork = true;

            Margins m = new Margins();
            m.Bottom = 50;
            m.Top = 50;
            m.Left = 50;
            m.Right = 50;
            pageSetupDialog1.PageSettings.Margins = m;
            PaperSize p = new PaperSize();
            p.PaperName = "A4";
            p.Width = 210;
            p.Height = 297;
            pageSetupDialog1.PageSettings.PaperSize = p;


            pageSetupDialog1.PageSettings.Landscape = true;
            pageSetupDialog1.PrinterSettings.PrinterName = "HP LaserJet 4050 Series PS";
            pageSetupDialog1.PrinterSettings.FromPage = 1;
            pageSetupDialog1.PrinterSettings.ToPage = 10;
            pageSetupDialog1.AllowPrinter = true;
            DialogResult result = pageSetupDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {

            }
        }
    }
}